﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace ServerExplorer.SharePointConnections.SharepointSiteInfo.Entities
{
    [Serializable]
    public class WebPartInfo
    {
        private string _webPartTitle;
        private string _webPartType;
        private string _webPartPage;
        private string _open;

        [XmlIgnore]
        public string Open
        {
            get { return _open; }
            set { _open = value; }
        }

        [XmlAttribute("Name")]
        public string WebPartType
        {
            get { return _webPartType; }
            set { _webPartType = value; }
        }

        [XmlAttribute("Title")]
        public string WebPartTitle
        {
            get { return _webPartTitle; }
            set { _webPartTitle = value; }
        }

        [XmlAttribute("Page")]
        public string Page
        {
            get { return _webPartPage; }
            set { _webPartPage = value; }
        }

        public static implicit operator WebPartInfo(string obj)
        {
            return new WebPartInfo(obj);
        }

        private WebPartInfo(string val)
            : this()
        {
            string[] data = val.Split(':');
            _webPartType = data[0];
            _webPartTitle = data[1];
            _webPartPage = data[2];
            _open = data[3];
        }

        public WebPartInfo()
        {            
        }

        public override string ToString() { return WebPartType; }
    }
}
